using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAL;
using BUS;
using Utility;
public partial class Admin_D_Capnhattrangthaisanpham : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDropDownList();
            LoadData();
        }
    }
    private void LoadDropDownList()
    {
        tbTrangthaiCollection ttColl = tbTrangthaisanphamBUS.GetAll();
        dr_tt.DataTextField = tbTrangthaispColumn.Trangthai.ToString();
        dr_tt.DataValueField = tbTrangthaispColumn.Mattsp.ToString();
        dr_tt.DataSource = ttColl;
        dr_tt.DataBind();
    }
    private void LoadData()
    {
        string mdn = Session["madn"].ToString();
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_masp.Text = id.ToString();

            tbSanpham sp = tbSanphamBUS.GetByID(id);
            txt_tensp.Text = sp.Tensp;
            dr_tt.SelectedValue = sp.Mattsp.ToString();
            txt_lido.Text = sp.Lido;
        }
        catch
        {
            Response.Redirect("~/Admin/D_Sanphamdoanhnghiep.aspx?id="+ mdn.ToString());
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mdn = Session["madn"].ToString();
        //try
        //{
        int id = int.Parse(Request.QueryString["id"].ToString());
        tbSanpham sp = tbSanphamBUS.GetByID(id);
        sp.Mattsp = int.Parse(dr_tt.SelectedValue);
        tbSanphamBUS.Updatettdn(sp);
        //}
        //catch
        //{

        //}
        Response.Redirect("~/Admin/D_Sanphamdoanhnghiep.aspx?id="+mdn.ToString());
        Response.Redirect(Request.RawUrl);
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        string mdn = Session["madn"].ToString();
        Response.Redirect("~/Admin/D_Sanphamdoanhnghiep.aspx?id="+mdn.ToString());
    }
}
